﻿using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using ProjScan.RecordManager;
using ProjScan.RecordManager.AssetData;
using ProjScan.Submodules.CS_Check;
using ProjScan.Tools;

namespace ProjScan.ScanRule.CodeAnalysis
{
	// Token: 0x02000217 RID: 535
	internal abstract class InstructionRuleImpBase : RecordRuleImp<TypeDefinitionAssetData, TypeDefinitionRecordManager>
	{
		// Token: 0x17000358 RID: 856
		// (get) Token: 0x06000F4A RID: 3914 RVA: 0x0000719A File Offset: 0x0000539A
		public override bool HasWhiteList
		{
			get
			{
				return false;
			}
		}

		// Token: 0x06000F4C RID: 3916
		protected abstract bool AnalyzeInst(MethodDefinition method, Instruction inst, ref LineMapping failedSymbol);

		// Token: 0x06000F4D RID: 3917 RVA: 0x00044094 File Offset: 0x00042294
		protected override string GetFailedColumn()
		{
			return "路径行号";
		}

		// Token: 0x06000F4E RID: 3918 RVA: 0x0000A3A0 File Offset: 0x000085A0
		public override bool HasFailedInfos()
		{
			return true;
		}

		// Token: 0x06000F4F RID: 3919 RVA: 0x000440AC File Offset: 0x000422AC
		protected override string GetDetailCSVHeader()
		{
			return "Class,路径行号";
		}

		// Token: 0x06000F50 RID: 3920 RVA: 0x000440C4 File Offset: 0x000422C4
		protected override string GetDetailInfo(TypeDefinitionAssetData assetData, string failedInfo)
		{
			return base.GetDetailInfo(assetData, failedInfo) + failedInfo;
		}

		// Token: 0x06000F51 RID: 3921 RVA: 0x00044270 File Offset: 0x00042470
		protected override bool IsOK(TypeDefinitionAssetData assetData, ref string failedInfo)
		{
			bool flag = false;
			List<MethodDefinition> list = Enumerable.ToList<MethodDefinition>(assetData.typeDefinition.Methods);
			LineMapping lineMapping = new LineMapping();
			for (int i = 0; i < list.Count; i++)
			{
				MethodDefinition methodDefinition = list[i];
				bool hasBody = methodDefinition.HasBody;
				if (hasBody)
				{
					Collection<Instruction> instructions = methodDefinition.Body.Instructions;
					for (int j = 0; j < instructions.Count; j++)
					{
						Instruction instruction = instructions[j];
						bool flag2 = instruction != null && !this.AnalyzeInst(methodDefinition, instruction, ref lineMapping);
						if (flag2)
						{
							flag = true;
						}
					}
				}
			}
			bool flag3 = flag;
			bool result;
			if (flag3)
			{
				bool flag4 = lineMapping != null && !string.IsNullOrEmpty(lineMapping.ToString());
				if (flag4)
				{
					failedInfo = lineMapping.ToString() + AssemblyTools.I.GetAppendFullName(assetData.typeDefinition);
				}
				else
				{
					failedInfo = "Unknown";
				}
				result = false;
			}
			else
			{
				result = true;
			}
			return result;
		}
	}
}
